package com.yesjpt.dao;

import java.util.List;

import com.yesjpt.domain.book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


public interface BookDao {
    @Delete("delete from demo_book where id = #{id}")
    Integer deleteById(@Param("id") String id);

    @Insert("insert into demo_book(id, name) values(#{id}, #{name})")
    Integer add(book vo);

    //更新
    int update(book vo);

    // 仅更新书籍名称
    int updateName(book vo);

    /**
     * 根据书籍名称，查询书籍信息
     *
     * @param name 书籍名
     */
    @Select("select * from demo_book where name = #{name}")
    book findByName(@Param("name") String name);

    @Select("select * from demo_book where id = #{id}")
    book findById(@Param("id") String id);

    @Select("select * from demo_book t order by convert(t.name using gbk)")
    List<book> listAll();
}
